package com.jstorm.count.controller.network;

import com.jstorm.count.dto.CommonExecution;
import com.jstorm.count.dto.ResultDtoUtile;
import com.jstorm.count.enums.ResultEnum;
import com.jstorm.count.pojo.Result;
import com.jstorm.count.service.network.NetworkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * @ProjectName: springboot-mybatis
 * @Package: com.jstorm.count.controller.network
 * @ClassName: networkController
 * @Description:
 * @Author: Mr_hu
 * @CreateDate: 2018/12/29 10:08
 * ***********************************************************
 * @UpdateUser: Mr_hu
 * @UpdateDate: 2018/12/29 10:08
 * @UpdateRemark: The modified content
 * @Version: 1.0
 * ***********************************************************
 * Copyright: Copyright (c) 2018
 **/
@Controller
@RequestMapping("/network/*")
public class NetworkController {

    @Autowired
    private NetworkService networkService;

    @RequestMapping("/network-count")
    @ResponseBody
    public ResultDtoUtile NetworkCount(){
        CommonExecution networkExecution = networkService.selectSum();

        if (networkExecution == null){
            new ResultDtoUtile(networkExecution.getCode(),networkExecution.getMsg());
        }
        //返回成功
        return new ResultDtoUtile(networkExecution.getCode(),networkExecution.getMsg(),networkExecution.getList());
    }


    /**
     * 总数
     * @return
     */
    @RequestMapping("/network-total")
    public ResultDtoUtile selectTotal(){
        //进行service方法查找所有
        CommonExecution networkTotal = networkService.selectTotal();
        //返回失败，没有数据，或者出错了
        if (networkTotal == null){
            new ResultDtoUtile(networkTotal.getCode(),networkTotal.getMsg());
        }
        //返回成功
        //返回成功
        return new ResultDtoUtile(networkTotal.getCode(),networkTotal.getMsg(),networkTotal.getList());
    }


}
